You are here: LifeKeeper > User Guide > Using LifeKeeper > LifeKeeper API for Monitoring

LifeKeeper API for Monitoring

1. Introduction

 

The LifeKeeper API for Monitoring can obtain the operational status of LifeKeeper nodes and  their protected resources by making status inquiries to the available nodes in the LifeKeeper cluster.

 

2.Summary

This document describes the LifeKeeper API for Monitoring (hereinafter referred to as the API) and is targeted for developers who manage the resource protected by LifeKeeper.

By using the API, the information supplied by the lcdstatus command is obtained through CGI script and the lighttpd module. By using this API, users can determine the current status of the LifeKeeper nodes and resources without logging-in to LifeKeeper servers.

The API can supply the following information.

To get the detailed status of any abnormal condition requires logging-in to LifeKeeper GUI or checking the LifeKeeper log as necessary.

 

Chart 1. Overview of the LifeKeeper API for Monitoring

 

3.Information to be supplied with this API

The following information is supplied through this API when the user makes an inquiry to an active LifeKeeper node. The information supplied is about the specific LifeKeeper server to which the inquiry was directed even if the cluster consists of multiple servers.

4.Communication format

The API uses HTTP to obtain the requested information. To obtain information, the user sends a HTTP GET request to the CGI scripts via lighttpd on the specific server.

 

5.Data format

The following 3 data formats are available.

 

Available JSON format from the status in figure 2 is shown in figure 3, and HTML format is in figure 4

ss.png

Figure 2. Example of active LifeKeeper configuration

 

{

   "resource": [

       {

           "replication": {},

           "child": [

               {

                   "tag": "datarep-data"

               }

           ],

           "server": {

               "status": "ISP",

               "name": "lk01"

           },

           "tag": "/data"

       },

       {

           "replication": {

               "percent": "100%",

               "mirror": "Fully Operational"

           },

           "child": [],

           "server": {

               "status": "ISP",

               "name": "lk01"

           },

           "tag": "datarep-data"

       },

       {

           "replication": {},

           "child": [],

           "server": {

               "status": "ISP",

               "name": "lk01"

           },

           "tag": "ip-10.125.139.118"

       }

   ],

   "compath": [

       {

           "status": "ALIVE",

           "server": [

               {

                   "name": "lk01",

                   "term": "192.168.139.18"

               },

               {

                   "name": "lk02",

                   "term": "192.168.139.19"

               }

           ]

       },

       {

           "status": "ALIVE",

           "server": [

               {

                   "name": "lk01",

                   "term": "172.20.139.18"

               },

               {

                   "name": "lk02",

                   "term": "172.20.139.19"

               }

           ]

       }

   ],

   "server": [

       {

           "status": "ALIVE",

           "name": "lk01"

       },

       {

           "status": "ALIVE",

           "name": "lk02"

       }

   ]

}

Figure 3. Status output example using the JSON data format

SS.png

Figure 4. Status output using the HTML format

 

6.How to use

6.1.Activate the API

The API is disabled by default. To activate, requires modification of  /etc/default/LifeKeeper set the LKAPI_MONITORING configuration parameter to true (see figure 5).  Setting of the configuration parameter only activates the API on that node and therefore must be set on each node on which the API will be used.  Setting of this configuration parameter does not require a restart of LifeKeeper..

 

LKAPI_MONITORING=true

Figure 5. Enabling the LifeKeeper API for Monitoring

 

6.2Port number

The API uses port 779 by default. To change the port number, the user needs to set the following in /etc/default/LifeKeeper.

 

LKAPI_WEB_PORT=<port number>

Figure 6. Change the port number for LifeKeeper API for Monitoring

6.3.Usage examples


To obtain information a request is made to a server with an active LifeKeeper API configuration. Basic example using curl.

curl http://<IPADDR>:779/Monitoring.cgi

If no arguments are given, the current status is obtained using the JSON data format.

 

Request for log information using HTML data format.

curl  http://<IPADDR>:779/Monitoring.cgi?format=html&show=log

 

The list of available arguments can be found in the table below.

 

List 1. Arguments

Name

Explanation

Value

Comments

show

Specify the target information

status, log, log-err

show=status is the default

format

Specify data format

json, html, plain

format=json is the default.  If the format is json an error will be displayed if show=log or show=log-err is set.

 

 

7.Security

All the users requesting information via the API must be authorized to get LifeKeeper status information.

For this reason, user security settings can limit the users who can get the status by, configuring SSL, and encrypting the information.

 

7.1.Basic Authentication

To obtain the information via the API, Basic Authentication is required. To setup the authentication requires modification to the lighttpd configuration file (Modify the part in red colored character.) plus a restart of the lighttpd module.  See figure 7 for how to configure lightttp.conf.

After modification execute the command ”/opt/LifeKeeper/sbin/sv restart steeleye-lighttpd” and reboot lighttpd to restart lighttpd using the new configuration.

/opt/LifeKeeper/etc/lighttpd/lighttpd.conf

server.modules              = (

    :

                                   "mod_auth", # uncommenting

 

/opt/LifeKeeper/etc/lighttpd/conf.d/lkapi_user.conf

print qq/\$SERVER["socket"] == ":$lkapi_port" {\n/;

print qq/    server.document-root = "\/opt\/LifeKeeper\/api"\n/;

print qq/    auth.backend = "htpasswd"\n/;

print qq/    auth.backend.htpasswd.userfile = "\/opt\/LifeKeeper\/etc\/lighttpd\/lighttpd.user.htpasswd"\n/;

print qq/    auth.require = ( "\/" =>\n/;

print qq/        (\n/;

print qq/                    "method"  => "basic",\n/;

print qq/                    "realm"   => "LifeKeeperAPI",\n/;

print qq/                    "require" => "valid-user"\n/;

print qq/        )\n/;

print qq/    )\n/;

print qq/ }\n/;

 

Step to create htpasswd file.

htpasswd -c /opt/LifeKeeper/etc/lighttpd/lighttpd.user.htpasswd USERNAME

Figure 7. Basic Authentication setting example

 

7.2.SSL/TLS set up

SSL/TLS is available for the communication via this API.  The lighttpd modifications for SSL/TLS is shown in the example in Figure 8. After modification execute the command ”/opt/LifeKeeper/sbin/sv restart steeleye-lighttpd” and reboot lighttpd to restart lighttpd with the new configuration.

/opt/LifeKeeper/etc/lighttpd/include_ssl_port.pl

configAPI("0.0.0.0", 443);

if(socket($sock, AF_INET6, SOCK_STREAM, 0)) {

    configAPI("[::]", 443);

}

sub configAPI {

    my $addr = shift;

    my $port = shift;

 

    print qq/\$SERVER["socket"] == "$addr:$port" {\n/;

    print qq/    server.document-root = "\/opt\/LifeKeeper\/api"\n/;

    print qq/    ssl.engine  = "enable"\n/;

    print qq/    ssl.pemfile = "\/opt\/LifeKeeper\/etc\/certs\/LK4LinuxValidNode.pem"\n/;

    print qq/    ssl.use-sslv2 = "disable"\n/;

    print qq/    ssl.use-sslv3 = "disable"\n/;

    print qq/ }\n/;

}

 

Figure 8 SSL/TLS setting example

7.3.    Modification to support SSL/TLS + Basic authentication

Using SSL/TLS, modification example to set up Basic authentication is below. After modification, execute the command “/opt/LifeKeeper/sbin/sv restart steeleye-lighttpd“ and restart lighttpd to reflect the modified set up.

/opt/LifeKeeper/etc/lighttpd/lighttpd.conf

server.modules              = (

   :

                                  "mod_auth", # uncommenting

 

/opt/LifeKeeper/etc/lighttpd/include_ssl_port.pl

configAPI("0.0.0.0", 443);

if(socket($sock, AF_INET6, SOCK_STREAM, 0)) {

   configAPI("[::]", 443);

}

sub configAPI {

   my $addr = shift;

   my $port = shift;

 

   print qq/\$SERVER["socket"] == "$addr:$port" {\n/;

   print qq/    server.document-root = "\/opt\/LifeKeeper\/api"\n/;

   print qq/    ssl.engine  = "enable"\n/;

   print qq/    ssl.pemfile = "\/opt\/LifeKeeper\/etc\/certs\/LK4LinuxValidNode.pem"\n/;

   print qq/    ssl.use-sslv2 = "disable"\n/;

   print qq/    ssl.use-sslv3 = "disable"\n/;

 print qq/    auth.backend = "htpasswd"\n/;

 print qq/    auth.backend.htpasswd.userfile = "\/opt\/LifeKeeper\/etc\/lighttpd\/lighttpd.user.htpasswd"\n/;

 print qq/    auth.require = ( "\/" =>\n/;

 print qq/        (\n/;

 print qq/                    "method"  => "basic",\n/;

 print qq/                    "realm"   => "LifeKeeperAPI",\n/;

 print qq/                    "require" => "valid-user"\n/;

 print qq/        )\n/;

 print qq/    )\n/;

   print qq/ }\n/;

}

 

Figure 9. SSL/TLS+Basic Authentication set up example

 

7.4.IP address access limitation

The lightppd configuration can also be setup to limit IP addresses that can be used to access data via the API. The lighttpd configuration to limit access is shown in Figure 9.   The example will reject the connections from IP address other than 192.168.10.1. After modification execute the command ”/opt/LifeKeeper/sbin/sv restart steeleye-lighttpd” to restart lighttpd with the new configuration.

/opt/LifeKeeper/etc/lighttpd/conf.d/lkapi_user.conf

$HTTP["remoteip"] != "192.168.10.1" {

  url.access-deny = ( "" )

}

 

Figure 10. IP access limit setting example

8.Error

Errors can occur during the usage of this API when enabled. Should this occur, the summary of the error is output. Error example when JSON format is shown below.

HTTP status code returned by lighttpd is not described here.

{

  "error" : {

       id : -1,

       message : "Failed to get LCD status"

    }

}

Figure 11. Error output example

 

Similar message is output in the case the output format is HTML.

of

© 2017 SIOS Technology Corp., the industry's leading provider of business continuity solutions, data replication for continuous data protection.